//
//  WKMnemonicsVM.m
//  WuKongUsernameLogin
//
//  Created by tt on 2023/9/9.
//

#import "WKMnemonicsVM.h"
#import "WKBlockIconItemCell.h"
#import "WKUsernameLoginModule.h"
#import <WuKongBase/WuKongBase.h>
#import "WKAttentionItemCell.h"
#import "WKMnemonicsBackupVC.h"

@interface WKMnemonicsVM ()

@property(nonatomic,assign) NSInteger selectedCount;

@end

@implementation WKMnemonicsVM

- (NSArray<NSDictionary *> *)tableSectionMaps {
    CGFloat itemHeight = 60.0f;
    __weak typeof(self) weakSelf = self;
    return  @[
        @{
            @"height":@(40.0f),
            @"items":@[
                    @{
                        @"class":WKBlockIconItemModel.class,
                        @"width":@(80.0f),
                        @"height":@(80.0f),
                        @"icon": [self imageName:@"Blockicon"],
                    },
            ],
        },
        @{
            @"height":@(20.01f),
            @"items":@[
                    @{
                        @"class":WKLabelModel.class,
                        @"text":LLang(@"在下一步里，您将看到可以恢复钱包的助记词（12个单词），请谨记以下安全点！"),
                        @"left": @(40),
                        @"width": @(WKScreenWidth - 80.0f),
                        @"center":@(true),
                        @"font":[WKApp.shared.config appFontOfSizeMedium:16.0f],
                        @"textColor": WKApp.shared.config.defaultTextColor,
                    },
            ],
        },
        @{
            @"height":@(15.0f),
            @"items":@[
                    @{
                        @"class":WKAttentionItemModel.class,
                        @"content":LLang(@"如果我丢了助记词，我的资产将永远丢失！"),
                        @"cellHeight":@(itemHeight),
                        @"onCheck":^(BOOL on) {
                            if(on) {
                                weakSelf.selectedCount ++ ;
                            }else{
                                weakSelf.selectedCount -- ;
                            }
                        }
                    },
            ],
        },
        @{
            @"height":@(10.01f),
            @"items":@[
                    @{
                        @"class":WKAttentionItemModel.class,
                        @"content":LLang(@"如果我向任何人透露或分享我的助记词我的资产可能被盗！"),
                        @"cellHeight":@(itemHeight),
                        @"onCheck":^(BOOL on) {
                            if(on) {
                                weakSelf.selectedCount ++ ;
                            }else{
                                weakSelf.selectedCount -- ;
                            }
                        }
                    },
            ],
        },
        @{
            @"height":@(10.01f),
            @"items":@[
                    @{
                        @"class":WKAttentionItemModel.class,
                        @"content":LLang(@"保护好助记词的安全的责任全部在于我！"),
                        @"cellHeight":@(itemHeight),
                        @"onCheck":^(BOOL on) {
                            if(on) {
                                weakSelf.selectedCount ++ ;
                            }else{
                                weakSelf.selectedCount -- ;
                            }
                        }
                    },
            ],
        },
        @{
            @"height":@(80.0f),
            @"items":@[
                    @{
                        @"class":WKButtonItemModel2.class,
                        @"title": LLang(@"下一步"),
                        @"width": @(150.0f),
                        @"height":@(40.0f),
                        @"onPressed":^{
                            if(weakSelf.selectedCount>=3) {
                                WKMnemonicsBackupVC *vc = [WKMnemonicsBackupVC new];
                                [WKNavigationManager.shared pushViewController:vc animated:YES];
                            }else{
                                [WKNavigationManager.shared.topViewController.view showHUDWithHide:LLang(@"请勾选注意事项")];
                            }
                            
                        }
                    },
            ],
        },
    ];
}

- (UIImage*) imageName:(NSString*)name {
    return [[WKApp shared] loadImage:name moduleID:[WKUsernameLoginModule gModuleID]];
}

@end
